{extend name="public/base"}
{block name='main'}
<style type="text/css">
  .red {color: #FF5722!important;}
  .green {color: #5FB878!important;}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top:0px;">
  <legend>{$menuid|getmenuname}</legend>
</fieldset>
<form class="layui-form layui-form-pane" action="">
  <div class="my-btn-box">
      <span class="fl">
        <blockquote class="layui-elem-quote">提示：暂时制作二级分类。</blockquote>
     </span>
    <span class="fr">
        <a class="layui-btn layui-btn-normal" id="btn-add">添加分类</a>
     </span>
  </div>
</form>
<form class="layui-form layui-form-pane" action="">
  <table class="layui-table">
    <colgroup>
      <col width="50">
      <col width="">
      <col width="100">
      <col width="100">
      <col width="100">
      <col width="200">

    </colgroup>
    <thead>
    <tr>
      <th>ID</th>
      <th>分类名称</th>
      <th>文档数</th>
      <th>排序</th>
      <th>是否启用</th>
      <th>管理操作</th>
    </tr>
    </thead>
    <tbody id="userList">
    {volist name="list" id="val"}
    <tr>
      <td>{$val.id}</td>
      <td>{$val.html}{$val.name}</td>
      <td><span style="color:#009688;">{$val.id|getcatecount}</span></td>
      <td>{$val.ordid}</td>
      <td><input type="checkbox" name="status" value="{$val.status}" data-uri="{:url('category/ajax_edit',array('field'=>'status','id'=>$val['id']))}" lay-skin="switch" lay-filter="status" lay-text="启用|禁止" {if($val.status == 1)}checked{/if} >
        <div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch"><em>启用</em><i></i></div></td>
      <td>
        {if($val.count<1)}
        <a href="javascript:;" data-uri="{:url('category/add', array('pid' => $val['id']))}" data-title="添加子分类 - 实用文档" id="add">添加子分类</a> |
        {/if}
        <a href="javascript:;" data-uri="{:url('category/edit', array('id' => $val['id']))}" data-title="编辑 - 实用文档" id="edit">编辑</a> |
        <a href="javascript:;" data-acttype="ajax" class="J_confirmurl" id="delete" data-uri="{:url('category/delete', array('id' => $val['id']))}" data-msg="确定要删除“实用文档”吗？">删除</a></td>
    </tr>
    {/volist}
    {//$list}
    </tbody>

  </table>
</form>
<div id="test-laypage-demo0">
  <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-29">
    {//$list|raw}
  </div>
</div>
<script type="text/javascript" src="__PUBLIC__/admin/layui/layui.js"></script>
<script>
  //Demo
  layui.use(['layer','jquery','form','element','table'], function () {
    // 操作对象
    var layer = layui.layer,$ = layui.jquery,form = layui.form, element = layui.element,table = layui.table;

    //添加二级
    $(function(){
      $("tbody#userList tr td #add").click(function() {
        var s_title   = $(this).attr('data-title'), s_url = $(this).attr('data-uri') ;
        layer.open({
          type: 2,
          title: s_title,
          area: ['600px', '420px'],
          fixed: true, //不固定
          maxmin: true,
          content: s_url
        });
      });
    });

    //参数：layui、名称、模块名、主键（删除用）
    //新增弹窗
    Oper.config.add.width = '600px';
    Oper.config.add.height = '420px';

    //编辑弹窗
    Oper.config.edit.width = '600px';
    Oper.config.edit.height = '420px';
    Oper.initList(layui, '文档分类', 'category', 'id');

  });
</script>
{/block}